package com.atguigu.gmall.search.bean;

import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.util.Date;

@Document(indexName = "person-data")
@Data
public class Person {
    @Id
    private Long id;

    @Field(type = FieldType.Text,analyzer = "ik_smart")
    private String username;

    @Field(type = FieldType.Text, analyzer = "ik_smart")  //全文检索
    private String address;

//    @Field(type = FieldType.Date, format = DateFormat.custom,
//            pattern = "yyyy-MM-dd HH:mm:ss")
    @Field(type = FieldType.Date,format = DateFormat.custom,pattern = "yyyy-MM-dd HH:mm:ss")
    private Date birthDay;

    @Field(index = false,type = FieldType.Long) //这个自动不用创建检索的倒排索引
    private Integer age;

}